package com.tarena.lbs.content.dao.repository;

import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.content.pojo.po.ActionSearchPO;
import com.tarena.lbs.content.pojo.po.ArticleSearchPO;
import com.tarena.lbs.content.pojo.query.ArticleQuery;
import com.tarena.lbs.content.pojo.vo.ArticleActionVO;
import com.tarena.lbs.content.pojo.vo.ArticleStatsVO;
import com.tarena.lbs.content.pojo.vo.ArticleVO;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

public interface ArticleRepository {
     ArticleSearchPO saveArticle(ArticleSearchPO article);

     PageResult<ArticleVO>findArticle(ArticleQuery query);

     Optional<ArticleSearchPO>findArticleById(String id);

     boolean existsArticleById(String id);

     void deleteArticleById(String id);

    Map<String, ArticleStatsVO> getBatchArticleStatsFromRedis(List<String> articleIds);

    void deleteArticleStatsFromRedis(String id);

    void incrementArticleStatInRedis(String id,String field, long value);

    ArticleStatsVO getArticleStatsFromRedis(String id);

    void refillArticleStatsToRedis(String id, ArticleStatsVO statsToRefill);


    PageResult<ArticleActionVO> findBehaviorsByUserId(Integer userId, int actionType, ArticleQuery query);

    PageResult<ArticleActionVO> findBehaviorsByArticleId(String articleId, int actionType, ArticleQuery query);

    Set<String> findUniqueLabelsByQuery(ArticleQuery query);

    void updateArticle(ArticleSearchPO existingArticle);

    void addArticleAction(ArticleSearchPO actionPO);

    void refillBatchArticleStatsToRedis(Map<String, ArticleStatsVO> refillMap);
}